﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace ConfExpert.Forms.Sistem
{
    public partial class OnlineUsers : XForm
    {
        public OnlineUsers()
        {
            InitializeComponent();
        }

        BindingSource bs;
        private void OnlineUsers_Load(object sender, EventArgs e)
        {
            bs = gv.Init("VersionCheck");
            bs.Filter = "Online=1";

            checkEdit1.CheckedChanged += CheckEdit1_CheckedChanged;
            gv.RowStyle += new DevExpress.XtraGrid.Views.Grid.RowStyleEventHandler(gv_RowStyle);

            gv.MakeColumnInvisible("Online");
            gv.FormatAsNumber(1, "ForHrs");

            gv.SetCaptions("ForHrs:HrsAgo", "LastLogin:LastLoggedIn");

            gv.OptionsView.EnableAppearanceEvenRow = 
            gv.OptionsView.EnableAppearanceOddRow = false;

            gv.AddSummary();
            gv.BestFitColumns();
        }

        void gv_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            if (gv.GetRowCellDisplayText(e.RowHandle, "NewestVersion") == "1")
                e.Appearance.BackColor = Color.LightBlue;
        }

        private void CheckEdit1_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            bs.Filter = checkEdit1.Checked ? string.Empty : "Online=1";
        }
    }
}
